<?php 
include("../config.php");
$featureid  = $_GET['featureid'];
$feature_id = $_GET['feature_id'];
###################################################ADD FEATURE###################################
$progid = $_POST["helptitle"];
$content = $_POST["content"];

$time = time();
if(($progid!="")&($content!="")&($featureid=="")){
$sql = "INSERT INTO features(progid,content,date) VALUES('$progid','$content',$time)";

$database->setQuery($sql);
	if($database->query()){
	//echo "<script>alert('successful submit the feature!');location.href('feature.php')</script>";
	}else {
	echo "<script>alert('fail to  submit the feature!');location.href('feature.php')</script>";	
	}

}
if(($progid!="")&($content!="")&($featureid!="")){
$sql = "UPDATE features SET progid='$progid',content='$content',date=$time WHERE featureid=$featureid";
$database->setQuery($sql);
	if($database->query()){
	echo "<script>alert('successful update the feature!');location.href('feature.php')</script>";
	}else{
	echo "<script>alert('fail to  update the feature!');location.href('feature.php')</script>";	
	}

}

###################################################MOD FEATURE###################################
if(isset($featureid)){
$sql = "SELECT * FROM  features where featureid=$featureid";
$database->setQuery($sql);
$result1=$database->loadAssocList();

}
###################################################DEL FEATURE###################################
if($feature_id!=""){
	$sql = "delete from features where featureid=$feature_id";
	$database->setQuery($sql);
	$database->query();
	header("Location:feature.php");
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0049)http://localhost/sharewareabc/sysop/customadd.php -->
<HTML><HEAD><TITLE><?php echo $sitename; ?> - Sysop: Add/Modify Feature</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="<?php echo $sitename; ?> - Sysop: Add/Modify feature" name=description>
<META content="free to try, software, shareware, freeware, developers, vendors, download, PAD" 
name=keywords>
<META content="Andrey Aleksanyants, M.D." name=author>
<META content="easy HTools" name=copyright>
<META http-equiv=imagetoolbar content=no><LINK 
href="../<?php echo $cssfile; ?>" 
type=text/css rel=stylesheet><LINK href="../favicon.ico" rel="shortcut icon">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR>
</HEAD>
<BODY>
<TABLE class=tmain cellSpacing=0 cellPadding=0 width="906" align=center>
  <TBODY>
  <TR>
    <TD class=tmain>
      <TABLE class=tlogo cellSpacing=0 cellPadding=4 width="100%" 
        align=center><TBODY>
        <TR>
          <TD align=right>
            <P><A href="index.php">Home</A></P></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD class=tmain><BR>
      <TABLE cellSpacing=0 cellPadding=1 width="100%" align=center border=0>
        <TBODY>
        <TR vAlign=top>
          <TD align="center" class=tbody>
            <H1><?php echo $sitename?> - Sysop: Add/Modify Feature </H1>
            <FORM name=addhelp  action="feature.php?featureid=<?php echo $featureid?>"   method=post>
            <TABLE class=tvisible cellSpacing=0 cellPadding=4 width=640 
            align=center>
              <TBODY>
              <TR>
                <TH class=tablehead colSpan=2>Add/Modify Feature </TH>
              </TR>
              <TR>
                <TD class=tdark><LABEL for=$progid>
                  <P><B>Feature Porgid:</B></P>
                  </LABEL></TD>
                <TD ><INPUT class=text maxLength=20 size=8 name=helptitle value="<?php echo $result1[0]["progid"]?>">
                             
                </TD>
              </TR>
              <TR>
                <TD class=tdark><LABEL for=customurl>
                  <P><B>Fearture Content :</B></P>
                  </LABEL></TD>
                <TD><textarea name="content" cols="60" rows="6" class="text" id="customurl" style="background-color:D7F8AB" ><?php echo $result1[0]["content"]?></textarea></TD></TR>
              <TR>
                <TD class=tdark>
                  <P><B>Submit:</B></P></TD>
              <TD><INPUT class=button type=submit value="  Submit  " name=submit></TD></TR></TBODY></TABLE></FORM><BR>
              <BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<table width="906" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="23" align="center" class="tablehead"><strong>No</strong></td>
    <td width="31" align="center" class="tablehead"><strong>Progid </strong></td>
    <td width="563" align="center" class="tablehead"><strong>Content</strong></td>
    <td  align="center" class="tablehead"><strong>Date</strong></td>
    <td width="23" align="center" class="tablehead"><strong>Modify</strong></td>
    <td width="28" align="center" class="tablehead"><strong>delete</strong></td>
  </tr>
<?php 
###################################################LIST HELP###################################
$sql = "SELECT * FROM  features ORDER BY date DESC ";
$database->setQuery($sql);
$result=$database->loadAssocList();
$total = count($result);
$perpage = 20;
$pagebarnum = 10;
$url = "./feature.php";
$nowindex =$_GET['page'];
if($nowindex=="")$nowindex=1;
$begin = ($nowindex-1)*$perpage;
$sql = "SELECT * FROM  features ORDER BY date DESC limit $begin,$perpage";
$database->setQuery($sql);
$result=$database->loadAssocList();
$page = new Page($total,$perpage,$pagebarnum,$nowindex,$url);
$no=0;
foreach ($result as $row){ 
	  $no++;
	  $progid	 = $row['progid'];
	  $content   = substr($row['content'],0,300);
	  $featureid	 = $row['featureid'];
	  $date		 = date('Y-m-j',$row['date']);
	  echo "<tr>
    <td align=\"center\">$no</td>
    <td align=\"center\">$progid</td>
    <td align=\"center\">$content</td>
    <td align=\"center\">$date</td>
    <td align=\"center\"><a href=\"feature.php?featureid=$featureid\">MOD</a></td>
    <td align=\"center\"><a href=\"javascript:if(confirm('do you delete this feature?'))location='feature.php?feature_id=$featureid'\">DEL</a></td>
  </tr>";
}
?>
  
  <tr>
    <td colspan="6" align="center"><strong><?php echo $page->show($model=2);?></strong></td>
  </tr>
</table>
</BODY></HTML>